package middlewares

import (
	"github.com/gin-gonic/gin"
	"log"
)

// LoggingMiddleware 记录请求的日志
func LoggingMiddleware() gin.HandlerFunc {
	return func(c *gin.Context) {
		// 在请求到达之前记录请求信息
		log.Printf("Incoming request: %s %s", c.Request.Method, c.Request.URL.Path)

		// 请求结束后，记录响应信息
		c.Next()

		// 记录响应状态码
		log.Printf("Response status: %d", c.Writer.Status())
	}
}
